import { Suspense } from 'react'
import { HashRouter, Route, Routes, Navigate } from 'react-router-dom'
import routerList from './Routerconfig'
import {RouterItem} from '../e'
interface Props {

}
const renderRouter = (arr:RouterItem[]) => {
   return arr.map((i:RouterItem, j:number) => {
        return <Route key={j} path={i.path} element={i.to ? <Navigate to={i.to}></Navigate> : <i.element></i.element>}>
            {i.children&&renderRouter(i.children)}
        </Route>
    })
}
const RouterView = (props: Props) => {
    return (
        <Suspense fallback={<div>嘟嘟嘟嘟。。。。</div>}>
            <HashRouter>
                <Routes>
                    {
                        renderRouter(routerList)
                    }
                </Routes>
            </HashRouter>
        </Suspense>
    )
}

export default RouterView
